package com.emailsystem.emailsystem.service.impl;

import com.emailsystem.emailsystem.domain.Email;
import com.emailsystem.emailsystem.service.EmailService;
import com.emailsystem.emailsystem.service.ServerService;
//import org.json.simple.JSONObject;
import com.alibaba.fastjson.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.net.ServerSocket;
import java.net.Socket;
import java.util.HashMap;

@Service
public class EmailServiceImpl implements EmailService {
    @Autowired
    private ServerService serverService;
    public JSONObject sendEmail(Email email){
        //email->报文
        JSONObject message = new JSONObject();
        message.put("sender", email.getSender());
        message.put("receiver", email.getReceiver());
//        message.put("subject", email.getSubject());
//        message.put("content", email.getContent());
//        message.put("sendTime", email.getSendTime());
//        message.put("attachment", email.getAttachment());
        return message;
    }

    @Override
    public void receiveEmail(){
        serverService.runServer();
    }

    @Override
    public Email getEmailByEmailID(String emailID) {
        return null;
    }


}
